package bairui.international.console.web.controller.branch.branch.staff;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.servlet.ModelAndView;

import com.lianjing.sh.project.config.web.Project_Config_Web_PageTemplate;
import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.module.context.ModuleContext;
import com.lianjing.sh.spring.web.controller.enhance.navigations.context.NavigationContext;

import bairui.international.model.domain.jpa.TB_BranchCompanyStaff;
import bairui.international.model.status.State_User;
import bairui.international.service.Service_BranchCompanyStaff;

/**
 *
 * 详情
 *
 * @generated
 * 
 * @see STest_C_BranchCompanyStaff_Detail_DetailAccess 测试
 *
 */
@Controller
public class C_BranchCompanyStaff_Detail_DetailAccess
 extends SC_BranchCompanyStaff_Detail_DetailAccess 
{
	
	@Autowired private Service_BranchCompanyStaff service_BranchCompanyStaff;
	
	/**
	 * 访问详情页面
	 */
	@SuppressWarnings("serial")
	@Action(DetailAccess.class)
	@GetMapping(DetailAccess.RequestMappingValue)
	public ModelAndView detailAccess(
		ModelMap map, HttpServletRequest request,
		NavigationContext navigationContext, ModuleContext moduleContext, 
		@PathVariable(name=DetailAccess.PathVariableName.BranchId) long branchId, 
		@PathVariable(name=DetailAccess.PathVariableName.Id) long id
	) throws Exception {
		TB_BranchCompanyStaff bean = service_BranchCompanyStaff.findById(id);
		/* 模块 */
		moduleContext
			.addModule(module_Info.module(
					new Module_Info_OutputModel(bean){
						@Override protected void assign_before() {
							bean.setDimensionalUrl(
									new C_BranchCompanyStaff_ShowQRImg_ShowImg.ShowImg.Operate() {
										@Override public Object getId() {
											return bean.getId();
										}
										@Override public Object getBranchId() {
											return branchId;
										}
									}.getUrl()
								);
						}
						@Override public String assignAvatarUrl() {
							return bean.getUser().getAvatarUrl();
						}
						@Override public String assignNickName() {
							return bean.getUser().getNickName();
						}
						@Override public String assignRealName() {
							return bean.getUser().getRealName();
						}
						@Override public String assignPhone() {
							return bean.getUser().getPhone();
						}
						@Override public java.util.Date assignCreateTime() {
							return bean.getUser().getCreateTime();
						}
						@Override public State_User assignState() {
							return bean.getUser().getState();
						}
					},
					new C_BranchCompanyStaff_Delete_Delete.Delete.Operate(){
						@Override public Object getBranchId() { return branchId; }
						@Override public Object getId() { return id; }
					},
					new C_BranchCompanyStaff_UpDirector_Submit.Submit.Operate(){
						@Override public Object getBranchId() { return branchId; }
						@Override public Object getId() { return id; }
						@Override public boolean displaied() {
							return !bean.getDirectorFlag();
						}
					},
					new C_BranchCompanyStaff_CancelDirector_Submit.Submit.Operate(){
						@Override public Object getBranchId() { return branchId; }
						@Override public Object getId() { return id; }
						@Override public boolean displaied() {
							return bean.getDirectorFlag();
						}
					}
				));
		if(bean.getDirectorFlag()){
			moduleContext
				.addModule(module_SubPage.module(
						new C_BranchCompanyStaff_Detail_Page.Page.Operate(){
							@Override public Object getBranchId() { return branchId; }
							@Override public Object getId() { return id; }
						}, 
						new C_BranchCompanyStaff_AddSub_PageAccess.PageAccess.Operate(){
							@Override public Object getBranchId() { return branchId; }
							@Override public Object getId() { return id; }
						},
						new C_BranchCompanyStaff_Detail_Delete.Delete.Operate(){
							@Override public Object getBranchId() { return branchId; }
							@Override public Object getId() { return id; }
							@Override public Object getSubId() {
								return "{{:id}}";
							}
						}
					));
		}else{
			moduleContext
				.addModule(this.module_CustomerPage.module(
						new C_BranchCompanyStaff_Detail_CustomerPage.CustomerPage.Operate(){
							@Override public Object getBranchId() { return branchId; }
							@Override public Object getId() { return id; }
						}
					));	
		}
		//
		return Project_Config_Web_PageTemplate.Admin_Common(request);
	}
	

}
